package services

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"ruoyi-go/app/admin/dao"
	"ruoyi-go/app/admin/entity"
	"ruoyi-go/utils/R"
)

// InRecordsPage 分页查询
func InRecordsPage(context *gin.Context) {
	var req entity.InRecordsPageReq
	if err := context.ShouldBindJSON(&req); err != nil {
		context.JSON(http.StatusOK, R.ReturnFailMsg("获取参数失败"))
	} else {
		res := dao.InRecordPage(req)
		context.JSON(http.StatusOK, res)
	}
}

// InRecordsSave 新增
func InRecordsSave(context *gin.Context) {
	var req entity.InRecords
	if err := context.ShouldBindJSON(&req); err != nil {
		context.JSON(http.StatusOK, R.ReturnFailMsg("获取参数失败"))
	} else {
		res := dao.InRecordsSave(req)
		context.JSON(http.StatusOK, res)
	}
}

// InRecordsDelete 批量删除
func InRecordsDelete(context *gin.Context) {
	ids := context.Param("ids")
	result := dao.InRecordsDelete(ids)
	context.JSON(http.StatusOK, result)
}

// GetInRecordsById 根据id查询
func GetInRecordsById(context *gin.Context) {
	id := context.Param("id")
	res := dao.GetInRecordsById(id)
	context.JSON(http.StatusOK, res)
}
